﻿/*----------------------------------------------------------------
    // Copyright (C) 2009 江苏华招网
    // 版权所有。 
    // 作者：吕海乐
    //
    // 文件名：LogList.cs
    // 文件功能描述：日志管理
    // 创建标识：吕海乐2009-05-26
    //
    // 修改标识：
    // 修改描述：
    //
    // 修改标识：
    // 修改描述：
    //
    // 审核人：
// 审核时间：
// 审核说明：
 //----------------------------------------------------------------*/
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HZ.DrugTrade.Model;
using HZ.DrugTrade.IBLL;
using HZ.DrugTrade.BLLFactory;
using HZ.DrugTrade.Model.Enum;

namespace HZ.DrugTrade.Web.Admin.SystemManage
{
    public partial class LogList : BasePage
    {
        public LogList()
        {
            this.ModuleNo = Module.系统管理.ToString();
            this.PageOperateType = OperateType.日志管理.ToString();
        }

        IBLL_Log il = Factory.BLL_Log();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindLogInfo();
            }
        }

        /// <summary>
        /// 绑定操作日志
        /// </summary>
        private void BindLogInfo()
        {
            int totalCount;
            //AspNetPager1.PageSize = Constants.GRIDVIEW_PAGE_SIZE;
            KeyOperationLog log = new KeyOperationLog();
            log.Operator = txtOperator.Text.Trim().ToUpper();
            log.OperateTimeFrom = new HZ.Common.ConvertHelper(txtOperateTimeFrom.Text.Trim()).ToDateTime;
            log.OperateTimeTo = new HZ.Common.ConvertHelper(txtOperateTimeTo.Text.Trim()).ToDateTime;

            string role = ddlRole.SelectedItem.Value;    //updated by lhl 2009-08-28
            if (role == "0")                       //医疗机构
            {
                log.OrgID = "OrgID like 'H%'";
            }
            else if (role == "1")                //配送企业
            {
                log.OrgID = "OrgID like 'P%'";
            }
            else if (role == "2")                 //管理中心
            {
                log.OrgID = "OrgID not like '[H,P]%'";
            }
            
            IList<KeyOperationLog> logList = il.GetKeyOperationLogByWhere(log, AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out totalCount);
            AspNetPager1.RecordCount = totalCount;
            gvwLog.DataSource = logList;
            gvwLog.DataBind();
        }

        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnQuery_Click(object sender, EventArgs e)
        {
            AspNetPager1.CurrentPageIndex = 1;
            BindLogInfo();
        }

        /// <summary>
        /// 分页
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void AspNetPager1_OnPageChanged(object sender, EventArgs e)
        {
            BindLogInfo();
        }
    }
}
